import { createApp } from "vue";
import App from "./App.vue";
import ElementPlus, { ElMessage, ElLoading, ElMessageBox } from "element-plus";
import "element-plus/dist/index.css";
// @ts-ignore
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import router from "@/router";
import { apiUrl, next } from "@/util";
import "./assets/style/index";
import TreeElMenu from "@/components/TreeElMenu.vue";
import LayoutPage from "@/components/LayoutPage.vue";

function msg(message: string, type: typeof msgTypes[number] = "error") {
  ElMessage({ message, type });
}
export const app = createApp(App),
  msgTypes = ["success", "warning", "error", "info"] as const,
  exg = { ElMessage, ElLoading, ElMessageBox, msg, apiUrl, msgTypes, next };
for (const key in exg) {
  // @ts-ignore
  globalThis[key] = exg[key];
}
const gc = { TreeElMenu, LayoutPage };
Object.keys(gc).forEach(k => {
  app.component(k, gc[k]);
});
app
  .use(router)
  .use(ElementPlus, { locale: zhCn })
  .mount("#app");
